import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:flutter_widgets_pc/utils/toast_util.dart';
import 'package:flutter_widgets_pc/widgets/titleBar/kq_title_bar.dart';
import 'package:flutter_widgets_pc/widgets/gridView/kq_selectable_grid_view.dart';

class KqSelectableGridViewDemo extends StatefulWidget {
  const KqSelectableGridViewDemo({super.key});

  @override
  State<StatefulWidget> createState() => KqSelectableGridViewDemoState();
}

class KqSelectableGridViewDemoState extends State<KqSelectableGridViewDemo> {
  List<IGridViewItemData> test = [
    IGridViewItemData("title1", isSelected: false, isUsed: false),
    IGridViewItemData("title2", isSelected: false, isUsed: false),
    IGridViewItemData("title3", isSelected: false, isUsed: false),
    IGridViewItemData("title4", isSelected: false, isUsed: false),
    IGridViewItemData("title5", isSelected: false, isUsed: true),
    IGridViewItemData("title6", isSelected: false, isUsed: false),
    IGridViewItemData("title7", isSelected: false, isUsed: false),
    IGridViewItemData("title8", isSelected: false, isUsed: false),
    IGridViewItemData("title9", isSelected: true, isUsed: false),
    IGridViewItemData("title0", isSelected: false, isUsed: false),
    IGridViewItemData("title01", isSelected: false, isUsed: false),
    IGridViewItemData("title02", isSelected: false, isUsed: false),
    IGridViewItemData("title03", isSelected: false, isUsed: false),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: KqHeadBar(
        headTitle: '可选择的gridview',
        back: () {
          Get.back();
        },
      ),
      body: KqSelectableGridView(
        items: test,
        onTap: (data) {
          if (data != null) {
            KqToast.showNormal(data.title);
          }
        },
      ),
    );
  }
}
